import React, {Component} from 'react'
import { EditorState, convertToRaw, ContentState } from 'draft-js';
import { Editor } from 'react-draft-wysiwyg';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import draftToHtml from 'draftjs-to-html';
export default class RichTextEditor extends Component {

  state={
    editorState: EditorState.createEmpty()
  }

  getDetail = ()=>{
    const detail=draftToHtml(convertToRaw(this.state.editorState.getCurrentContent()))
    return detail
  }
  onEditorStateChange = (editorState) => {
    this.setState({
      editorState,
    });
  };

  render () {

    const {editorState} = this.state

    return (
      <Editor
        editorState={editorState}
        onEditorStateChange={this.onEditorStateChange}
        editorStyle = {{border:'1px solid #000',height: 200,padding:'0 10px'}}
      >
      </Editor>
    )
  }
}

